package com.cs2340.taskplusplus;


import java.util.Date;
import junit.framework.Assert;
import android.test.AndroidTestCase;

// I'm doing addTask and addLabel
// Charles: expand and task to tasklist constructor
// AJ: isDone isNotDone
// Adam: sorting methods


public class JUnitJason extends AndroidTestCase
{

	private Account account;
	private TaskList list;
	private Task task;
	private Label label;
	
	public JUnitJason(){
    	account = new Account("default");
    	account.deleteAccount("test");
        account = new Account("test", "asdf", "asdf", "asdf");
        list = account.getMasterList();
        
  
	}
	
	
    public void testAccountAttributes() throws Throwable
    {
        account.setPassword("pass");
        account.setRealname("real");
        account.setEmail("a@a.com");
    	Assert.assertEquals("test", account.getUsername());
    	Assert.assertEquals("pass", account.getPassword());
    	Assert.assertEquals("real", account.getRealname());
    	Assert.assertEquals("a@a.com", account.getEmail());
    	
    }
	
    public void testAddLabel() throws Throwable
    {
    	
    	list.addLabel(new Label("test_MasterList", "LABEL1"));
    	Assert.assertEquals("LABEL1", list.getLabels().get(0).getName());
    	Assert.assertEquals(1, list.getLabels().size());
    	
    	list.addLabel(new Label("test_MasterList", "LABEL1"));
    	Assert.assertEquals(1, list.getLabels().size());
    	
    	list.addLabel(new Label("test_MasterList", "LABEL2"));
    	Assert.assertEquals("LABEL2", list.getLabels().get(1).getName());
    	Assert.assertEquals(2, list.getLabels().size());
    }
	
    
    public void testAddTask() throws Throwable
    {
    	task = new Task(null, "TASKNAME1", "TASKDESCRIPTION1", new Date(), null, new Location(0,0));
    	list.addTask(task);
    	
    	Assert.assertEquals(1, list.getList().size());
    	Assert.assertEquals("TASKNAME1", list.getList().get(0).getName());
    	Assert.assertEquals("TASKDESCRIPTION1", list.getList().get(0).getDescription());
    	
    	
    	label = new Label("test_MasterList", "LABEL1");
    	list.addLabel(label);
    	task.addLabel(label);
    	Assert.assertEquals("LABEL1", list.getList().get(0).getLabels().get(0).getName());
    	
    }
    
    public void testCurrentLocation() throws Throwable
    {
    	CurrentLocation.setLat(12345);
    	CurrentLocation.setLon(54321);
    	Assert.assertEquals(CurrentLocation.getLat(), 12345);
    	Assert.assertEquals(CurrentLocation.getLon(), 54321);
    	CurrentLocation.setLat(11111);
    	CurrentLocation.setLon(22222);
    	Assert.assertEquals(CurrentLocation.getLat(), 11111);
    	Assert.assertEquals(CurrentLocation.getLon(), 22222);    	
    }
    
    
}
